<?php
/**
 * Created by 784855684@qq.com.
 * Link: https://github.com/lichtung/wshore
 * User: linzh
 * Date: 7/8/17
 * Time: 10:29 AM
 */
declare(strict_types=1);


namespace application\module\admin\addon\wechat\entity;

use application\module\admin\addon\wechat\throws\WechatException;
use wshore\helper\traits\Magic;

/**
 * Class Member
 *
 * //----------------- 网页授权得到的信息 -----------------------------//
 * @property string $openid     微信openid
 * @property string $nickname   昵称
 * @property int $sex           性别,男-1
 * @property string $language   语言,默认zh_CN
 * @property string $city       城市
 * @property string $province   省份
 * @property string $country    国家
 * @property string $headimgurl 头像地址
 *
 * @property string $subscribe
 * @property string $subscribe_time
 * @property string $remark
 * @property string $groupid
 *
 * @package application\module\admin\addon\wechat\entity
 */
class Member
{
    use Magic;

    public function __construct(array $userinfo)
    {
        if (empty($userinfo['headimgurl'])) {
            throw new WechatException('获取微信信息失败');
        }
        # web授权可以拿到下列信息
        $this->openid = $userinfo['openid'];
        $this->nickname = $userinfo['nickname'];
        $this->sex = $userinfo['sex'];
        $this->language = $userinfo['language'];
        $this->city = $userinfo['city'];
        $this->province = $userinfo['province'];
        $this->country = $userinfo['country'];
        $this->headimgurl = $userinfo['headimgurl'];


    }

}